
package thes2sim;

import data_queuing.*;
import event_classes.*;
import application.*;
import thes2sim.PDU;

import java.util.Random;

public class Thes2Sim {
   

    public static void main(String[] args) {
        // TODO code application logic here
       
        
        PDU u;
        int countID = 1;
        
        EventController ec = new EventController(Util.seed, Util.nFrames, Util.hRatio, Util.mRatio, Util.lRatio, Util.freqTx);
        Node n = new Node();
        Event tmpEvt;

        // Initialize events in events queue
        ec.initEvents();
        //ec.printEventsInQueue();

        // Get head of event queue
        tmpEvt = ec.pollEventQueue();
        
        while (tmpEvt != null) {
            //process events; call TxQueue
            
            if ( tmpEvt.getSchedule() > ec.getSimTime() ) {
                ec.moveToTime( tmpEvt.getSchedule() );
            }
            
            switch ( tmpEvt.getType() ) {
                case 0:
                    n.getRqa().transmitFrame(ec.getSimTime());

                    break;
                case 1:
                    u = new PDU(tmpEvt.getSchedule(), 1);
                    n.getRqa().queuePDU(u, countID, ec.getSimTime());
                    countID++;
                    
                    break;
                case 2:
                    u = new PDU(tmpEvt.getSchedule(), 2);
                    n.getRqa().queuePDU(u, countID, ec.getSimTime());
                    countID++;
                    
                    break;
                case 3:
                    u = new PDU(tmpEvt.getSchedule(), 3);
                    n.getRqa().queuePDU(u, countID, ec.getSimTime());
                    countID++;

                    break;
            }

            ec.incSimTime();
            tmpEvt = ec.pollEventQueue();
            
        }
        
        n.getRqa().printQContent();
             
    }
    
}
